<!doctype html>
<html>
<?php echo $this->fetch('head.html'); ?>

<body>
  <div class="fullscreen">
        <div class="scroll_content">
            <div class="topfixed">
				<div class="t_left"><a href="/index.php"><i class="back"></i></a></div>
                <div class="t_main">购物车</div>
            </div>
            <div class="paddingheight"></div>
			 
            <ul class="cart_new_list clearfix">
            <?php $_from = $this->_var['ymcart']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
                <li url="/index.php?m=ymdian_order_cart&a=add&ajax=1">
                    <div class="d_name"><span class="fl"><?php echo $this->_var['c']['title']; ?>（夜猫寝长）</span><span class="fr"><a href="javascript:;" class="cart_clear" url="/index.php?m=ymdian_order_cart&a=clear&shopid=<?php echo $this->_var['c']['id']; ?>">清空</a></span></div>
                    <?php $_from = $this->_var['c']['products']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'p');if (count($_from)):
    foreach ($_from AS $this->_var['p']):
?>
                    <div class="list clearfix">
                        <div class="cart_pic">
                            <a href=""><img src="<?php echo images_site($this->_var['p']['imgurl']); ?>.100x100.jpg" class="img"></a>
                        </div>
                        <div class="cart_content">

                            <div class="tit"><?php echo $this->_var['p']['title']; ?></div>

                            <div class="info">

                                <p class="fl">
                                <?php if ($this->_var['p']['lower_price']): ?>
                                    <b class="red">￥<?php echo $this->_var['p']['lower_price']; ?></b>
                                    <del>￥<?php echo $this->_var['p']['price']; ?></del>
                                 <?php else: ?>
                                 <b class="red">￥<?php echo $this->_var['p']['price']; ?></b>
                                 <?php endif; ?>   
                                </p>
 
                                <p class="fr">
                                    <span class="cart_num"  object_id="<?php echo $this->_var['p']['object_id']; ?>" shopid="<?php echo $this->_var['c']['id']; ?>" productid="<?php echo $this->_var['p']['productid']; ?>">
                                    <a class="DisDe" href="javascript:void(0)"><i>-</i></a>
                                    <input disabled="" class="Amount" value="<?php echo $this->_var['p']['amount']; ?>" autocomplete="off" maxlength="3">
                                    <a class="Increase" href="javascript:void(0)"><i>+</i></a>
                                    </apan>
                                </p>

                            </div>
                        </div>
                    </div>
                    <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                     
                     
                    <div class="final_price">
                        <span class="fl">共计<a class="total_num"><?php echo $this->_var['c']['total_num']; ?></a>件，合计:<b class="red">￥<a class="total_money"><?php echo $this->_var['c']['total_money']; ?></a></b></span>
                        <span class="fr"><a href="/index.php?m=ymdian_order&a=confirm&shopid=<?php echo $this->_var['c']['id']; ?>" class="buy">去结算</a> </span>
                    </div>
                </li>
                <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                <?php $_from = $this->_var['kdcart']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
                <li url="/index.php?m=koudai_order_cart&a=add&ajax=1">
                    <div class="d_name"><span class="fl">66口袋</span><span class="fr"><a href="javascript:;" class="cart_clear" url="/index.php?m=koudai_order_cart&a=clear&shopid=<?php echo $this->_var['c']['id']; ?>">清空</a></span></div>
                    <?php $_from = $this->_var['c']['products']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'p');if (count($_from)):
    foreach ($_from AS $this->_var['p']):
?>
                    <div class="list clearfix">
                        <div class="cart_pic">
                            <a href=""><img src="<?php echo images_site($this->_var['p']['imgurl']); ?>.100x100.jpg" class="img"></a>
                        </div>
                        <div class="cart_content">

                            <div class="tit"><?php echo $this->_var['p']['title']; ?></div>

                            <div class="info">

                                <p class="fl">
                                <?php if ($this->_var['p']['lower_price']): ?>
                                    <b class="red">￥<?php echo $this->_var['p']['lower_price']; ?></b>
                                    <del>￥<?php echo $this->_var['p']['price']; ?></del>
                                 <?php else: ?>
                                 <b class="red">￥<?php echo $this->_var['p']['price']; ?></b>
                                 <?php endif; ?>   
                                </p>

                                <p class="fr">
                                    <span class="cart_num"  object_id="<?php echo $this->_var['p']['object_id']; ?>" shopid="<?php echo $this->_var['c']['id']; ?>" productid="<?php echo $this->_var['p']['productid']; ?>">
                                    <a class="DisDe" href="javascript:void(0)"><i>-</i></a>
                                    <input disabled="" class="Amount" value="<?php echo $this->_var['p']['amount']; ?>" autocomplete="off" maxlength="3">
                                    <a class="Increase" href="javascript:void(0)"><i>+</i></a>
                                    </apan>
                                </p>

                            </div>
                        </div>
                    </div>
                    <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                     
                     
                    <div class="final_price">
                        <span class="fl">共计<a class="total_num"><?php echo $this->_var['c']['total_num']; ?></a>件，合计:<b class="red">￥<a class="total_money"><?php echo $this->_var['c']['total_money']; ?></a></b></span>
                        <span class="fr"><a href="/index.php?m=koudai_order&a=confirm&shopid=<?php echo $this->_var['c']['id']; ?>" class="buy">去结算</a> </span>
                    </div>
                </li>
                <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                <?php $_from = $this->_var['shopcart']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
                <li url="/index.php?m=shop_order_cart&a=add&ajax=1">
                    <div class="d_name"><span class="fl"><?php echo $this->_var['c']['shopname']; ?></span><span class="fr"><a href="javascript:;" class="cart_clear" url="/index.php?m=shop_order_cart&a=clear&shopid=<?php echo $this->_var['c']['id']; ?>">清空</a></span></div>
                    <?php $_from = $this->_var['c']['products']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'p');if (count($_from)):
    foreach ($_from AS $this->_var['p']):
?>
                    <div class="list clearfix">
                        <div class="cart_pic">
                            <a href=""><img src="<?php echo images_site($this->_var['p']['imgurl']); ?>.100x100.jpg" class="img"></a>
                        </div>
                        <div class="cart_content">

                            <div class="tit"><?php echo $this->_var['p']['title']; ?></div>

                            <div class="info">

                                <p class="fl">
                                <?php if ($this->_var['p']['lower_price']): ?>
                                    <b class="red">￥<?php echo $this->_var['p']['lower_price']; ?></b>
                                    <del>￥<?php echo $this->_var['p']['price']; ?></del>
                                 <?php else: ?>
                                 <b class="red">￥<?php echo $this->_var['p']['price']; ?></b>
                                 <?php endif; ?>   
                                </p>

                                <p class="fr">
                                    <span class="cart_num"  object_id="<?php echo $this->_var['p']['object_id']; ?>" shopid="<?php echo $this->_var['c']['shopid']; ?>" productid="<?php echo $this->_var['p']['productid']; ?>">
                                    <a class="DisDe" href="javascript:void(0)"><i>-</i></a>
                                    <input disabled="" class="Amount" value="<?php echo $this->_var['p']['amount']; ?>" autocomplete="off" maxlength="3">
                                    <a class="Increase" href="javascript:void(0)"><i>+</i></a>
                                    </apan>
                                </p>

                            </div>
                        </div>
                    </div>
                    <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                     
                     
                    <div class="final_price">
                        <span class="fl">共计<a class="total_num"><?php echo $this->_var['c']['total_num']; ?></a>件，合计:<b class="red">￥<a class="total_money"><?php echo $this->_var['c']['total_money']; ?></a></b></span>
                        <span class="fr"><a href="/index.php?m=shop_order&a=confirm&shopid=<?php echo $this->_var['c']['shopid']; ?>" class="buy">去结算</a> </span>
                    </div>
                </li>
                <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
            </ul>
        </div>
    </div>
<script>
//数量加减
 
$(function(){
	$(".cart_clear").on("click",function(){
		var obj=$(this);
		$.get(obj.attr("url"),function(data){
			if(data.error){
				
			}else{
				obj.parents("li").remove();;
			}
		},"json")
	});
	
	$(document).on("click",".DisDe",function(){
		var obj=$(this);
		var p=obj.parents(".cart_num");
		var v=parseInt(p.find(".Amount").val());
		v=v-1;
		var shop=$(this).parents("li");
		if(v>=0){
			$.get(shop.attr("url"),{object_id:p.attr("object_id"),shopid:p.attr("shopid"),productid:p.attr('productid'),amount:v},function(data){
				if(data.error){
					alert(data.message);
				}else{
					if(v==0){
						obj.parents(".list").remove();
						shop.find(".total_num").html(data.data.num);
						shop.find(".total_money").html(data.data.total_money);
					}else{
						p.find(".Amount").val(v);
						shop.find(".total_num").html(data.data.num);
						shop.find(".total_money").html(data.data.total_money);
						var ptm=obj.parents("li").find(".p_total_money");
						var pprice=obj.parents("li").find(".p_price").html();
						ptm.html(parseInt(pprice)*v);
					}
				 
				 
				}
			},"json")
		}else{
			skyToast("数量不能少于1件");
		}
	});
	
	$(document).on("click",".Increase",function(){
		var obj=$(this);
		var p=obj.parents(".cart_num");
		var v=parseInt(p.find(".Amount").val());
		var nv=v+1;
		var shop=$(this).parents("li");
		$.get(shop.attr("url"),{object_id:p.attr("object_id"),shopid:p.attr("shopid"),productid:p.attr('productid'),amount:nv},function(data){
			if(data.error){
				alert(data.message);
			}else{
				p.find(".Amount").val(nv);
				shop.find(".total_num").html(data.data.num);
					shop.find(".total_money").html(data.data.total_money);
				var ptm=obj.parents("li").find(".p_total_money");
				var pprice=obj.parents("li").find(".p_price").html();
				ptm.html(parseInt(pprice)*nv);
			 
			}
		},"json")
		
		
	});
	
});
</script>
<?php $this->assign('botnav','cart'); ?>
 <?php echo $this->fetch('botnav.html'); ?>
 <?php echo $this->fetch('footer.html'); ?> 
</body>
</html>
